import { Controller, Get, Post, Body, Param, Query, Put } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { FamilyService } from './family.service';
import { CreateFamilyDto, FamilyPreferenceDto } from './dto/family.dto';

@ApiTags('家庭')
@Controller('families')
export class FamilyController {
  constructor(private readonly familyService: FamilyService) {}

  @Post()
  @ApiOperation({ summary: '创建家庭' })
  async createFamily(@Body() createFamilyDto: CreateFamilyDto) {
    return this.familyService.createFamily(createFamilyDto);
  }

  @Get(':id')
  @ApiOperation({ summary: '获取家庭信息' })
  async getFamily(@Param('id') id: string) {
    return this.familyService.getFamilyById(id);
  }
  
  @Post(':id/family')
  @ApiOperation({ summary: '更新家庭饮食偏好' })
  async updateFamily(
    @Param('id') id: string,
    @Body() preferences: CreateFamilyDto,
  ) {
    return this.familyService.updateFamily(id, preferences);
  }
}